<style>
.user-cate-list img {max-width:150px;max-height:150px;}
.user-cate-list td{vertical-align: middle !important;}
</style>
		{{template wxes/_user_wxes}}
		<ol class="breadcrumb">
		  <li><a href="/users/index"><i class="fa fa-home"></i>&nbsp;&nbsp;个人中心</a></li>
		  <li class="active">城市门店分类</li>
		</ol> 
		
       <hr>
       <div class="mb10 form-inline">
       	<a class="btn btn-primary" href="{{$this->Html->url('/user_cates/mine?model=WxStorefront')}}">全部门店分类</a>
       	<a class="btn btn-primary" href="{{$this->Html->url('/user_cates/add/WxStorefront')}}">新增门店分类</a>
       	
       	<a class="btn btn-primary" href="{{$this->Html->url('/wx_city_cates/add/WxStorefront')}}">新增城市门店分类</a>
       </div>
       <ul class="nav nav-tabs" role="tablist">
       	{{loop $cities $id $name}}
       		{{if !empty($id)}}
       			<li {{if $city_id==$id}}class="active"{{/if}}><a href="{{getSearchLinks($this->request,array('city_id'=>$id),array('city_id'))}}">{{$name}}</a></li>
       		{{/if}}
       	{{/loop}}
       </ul>
       <div class="ui-portlet user-cate-list">
    <table class="table table-striped table-hover">
    <?php
        $tableHeaders =  $this->Html->tableHeaders(array(
            '分类名称',
			'最后编辑时间',
            '操作',
        ));
        echo '<thead>'.$tableHeaders.'</thead>';
        $rows = array(); 
        foreach ($datalist AS $item) {
            $actions = ' ' . $this->Html->link('修改', array('controller'=>'wx_city_cates','action' => 'edit', $item['WxCityCate']['id']));
			
            $rows[] = array(
                '<img src="'.$this->Html->image($item['WxCityCate']['coverimg'],array('onlyurl'=>true)).'">'.$item['UserCate']['name'],
				$item['WxCityCate']['updated'],
                $actions,
            );
			foreach($item['children'] as $child)
			{
				$actions = ' ' . $this->Html->link('修改', array('controller'=>'wx_city_cates','action' => 'edit', $child['WxCityCate']['id']));
			
            	$rows[] = array(
                	'|----<img src="'.$this->Html->image($child['UserCate']['coverimg'],array('onlyurl'=>true)).'">'.$child['UserCate']['name'],
					$child['UserCate']['updated'],
               		$actions,
            	);
			}
        }
        echo $this->Html->tableCells($rows);
    ?>
    </table>
    </div>
<script>
$(function(){
	
	$('#city-cates').change(function(){
		window.location.href = "{{getSearchLinks($this->request,array(),array('city_id'))}}&city_id=" + this.value;
	})
})
</script>